<!DOCTYPE>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>支点信息</title>
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/laypage.css">

    <script src="/js/vue/vue.min.js"></script>
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/laypage/laypage.js" charset="utf-8"></script>
    <script src="/js/layer/layer.js" charset="utf-8"></script>
</head>
<body>
<section id="container">
<#include "sider.ftl">  <#--引入头部和导航栏-->
<#--本页为模板，请大家复制之后使用，不要直接在模板上加东西-->
<#--大家在测试自己的页面时，在controller中TestController     test3.do进行测试      在地址栏输入localhost:8080/test3.do-->
<section id="main-content">
    <section class="wrapper">
        <div class="table-agile-info">
            <div class="panel panel-default">
                <div class="panel-heading">
                    分支信息
                </div>
    <div id="app" >
            <form class="form-inline bg-info" role="form">
                查询条件：
                <div class="form-group">
                    <label class="sr-only" for="keyword">支点名称:</label>
                    <input type="text" class="form-control" id="keyword"  name="keyword" placeholder="支点名称">
                </div>
            <#--    <div class="form-group">
                    <label class="sr-only" for="userage">用户年龄:</label>
                    <input type="text" class="form-control" id="userage" placeholder="用户年龄">
                </div>-->
                <button type="button" id="findBranch" class="btn btn-success">查询支点</button>
                <button type="button" id="addBranchBtn" class="btn btn-danger">增加支点</button>
            </form>

            <div class="table-responsive">
                <table class="table">
                    <thead>
                    <tr class="success">
                        <th >编号</th>
                        <th>名称</th>
                        <th>电话</th>
                        <th>城市</th>
                        <th>详细地址</th>
                        <th>负责人</th>
                        <th>负责人电话</th>
                        <th>经度</th>
                        <th>维度</th>
                        <th>创建日期</th>
                        <th>审核状态</th>
                        <th>备注</th>
                        <th>财务统计</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr class="active" v-for="(item,index) in result">
                        <td>{{index+1}}</td>
                        <td><a  href="#" @click="editEvent(item.buuid)">{{item.bname}}</a></td>
                        <td>{{item.btelephone}}</td>
                        <td>{{item.bcity}}</td>
                        <td>{{item.blocation}}</td>
                        <td>{{item.uname}}</td>
                        <td>{{item.phone}}</td>
                        <td>{{item.blongitude}}</td>
                        <td>{{item.bdimension}}</td>
                        <td>{{item.bstartdate}}</td>

                        <td>
                            <span v-if="item.bstate==0" >未审核</span>
                            <span v-if="item.bstate==1" style="color:rgb(50,205,50)">审核通过</span>
                            <span v-if="item.bstate==2" style="color:red;">审核不通过</span>
                          <#-- {{#if item.bastate==0}}
                            未审核
                            {{/if}}
                            {{#if item.bastate==0}}
                            审核通过
                            {{/if}}
                            {{#if item.bastate==0}}
                            未通过
                            {{/if}}-->
                        </td>
                        <td>{{item.bdesc}}</td>
                        <td><a href="#" @click="countEvent(item.buuid)">详细内容</a></td>
                        <td><a href="#" @click="editEvent(item.buuid)">编辑</a>&nbsp;<a href="#" @click="delEvent(item.buuid)">删除</a></td>
                    </tr>
                    </tbody>
                    <tr>
                        <td colspan="3"><div id="pagenav"></div></td>
                    </tr>
                </table>
                </div>

    </div>
</div>
    </section>
    <#include "/foot.html"><#--引入底部-->
 </section>
</section>
</body>
</html>
<script type="text/javascript">
    var app=new Vue({
        el:"#app",
        data:{
            result:[]
        }
    });
    var getBranchList=function (curr) {
        $.ajax({
            type:"POST",
            url:"/branch/getBranchList.do",
            dataType:"json",
            data:{
                pageNo:curr||1,
                pageSize:5,
                keyword:$("#keyword").val()
            },
            success:function (msg) {
                app.result=msg.page;
                laypage({
                    cont:"pagenav",
                    pages:msg.totalPage,
                    skin:"#CD00CD",
                    first:"第一页",
                    last:"最后一页",
                    curr:curr||1,
                    jump:function (obj,first) {
                        if(!first){
                            getBranchList(obj.curr);
                        }
                    }
                });
            }
        });
    }
    getBranchList();
    $("#findBranch").click(function () {
        getBranchList();
        $("#keyword").val($("#keyword").val());
    });
    $("#addBranchBtn").click(function () {
        layer.open({
            type:2,
            title:"增加支点",
            fix:false,
            maxmin:true,
            shadeClose:true,
            area:['1100px','500px'],
            content:"/branch/toadd.do",
            end:function () {
                getBranchList();
            }
        });
    });
   var countEvent=function (id) {
       layer.open({
           type:2,
           title:"查看分支统计",
           fix:false,
           maxmin:true,
           shadeClose:true,
           area:['1100px','500px'],
           content:"/branch/tobranchcount.do?buuid="+id,
           end:function () {
               getBranchList();
           }

       });
   }

   var editEvent=function (id) {
       layer.open({
           type:2,
           title:"修改支点信息",
           fix:false,
           maxmin:true,
           shadeClose:true,
           area:['1100px','500px'],
           content:"/branch/getBranch.do?buuid="+id,
           end:function () {
               getBranchList();
           }
       });
   }
   var delEvent=function (id) {
       layer.confirm("你确定要删除吗?",{
           btn:["残忍删除","考虑考虑"]
       },function () {
           $.ajax({
               type:"POST",
               url:"/branch/updateTodel.do",
               data:{
                   buuid:id
               },
               contextType:"application/json",
               success:function () {
                  getBranchList();
                  layer.msg("删除分支成功",{icon:6,time:1000})
               }
           });
       },function () {
           //不删除情况
       })
   }
</script>